import React ,{Component} from 'react'
import PropTypes from 'prop-types'
import {
    Form,
    Input
  } from 'antd'
  const Item = Form.Item
//更新分类的form组件
class UpdateForm extends Component{

     static propTypes = {
        categoryName:PropTypes.string.isRequired,
        setForm:PropTypes.func.isRequired
     }

     componentWillMount(){
        this.props.setForm(this.props.form);
     }


     render(){

      const { getFieldDecorator } = this.props.form;
      const { categoryName } = this.props;
      return (
          <form>
           <Item>
           { 
            getFieldDecorator('categoryName',{
                initialValue: categoryName,
                rules: [
                    {required: true, message: '分类名称必须输入'}
                ]
             }
            )(
               <Input placeholder='请输入分类名称'/>
            )
           }
           </Item>
         </form>
        )
    }
}


export default  Form.create()(UpdateForm)